#include "main.hpp"
#include "app.hpp"
#include "sorfttimer_v2.hpp"
#include "app.hpp"
#include "ws_client_app.hpp"

using namespace std;

#define SERVER_SORFT_VERSION "CAMERA_LINUX_V0.1.3"

uint8_t app_thread_create(thread_cb_t cb)
{
    pthread_t thread; // 创建处理图片数据的线程
    int rtn = pthread_create(&thread, NULL, (void *(*)(void *))cb, NULL);
    if (rtn != 0)
    {
        return 1;
    }
    return 0;
}

static void sorfttimer_process(void *argfd)
{
    for (;;)
    {
        st_sorft_timer_counter_prosess();
        usleep(1000);
    }
}

int main(void)
{
    st_sorft_timer_init();

    app_thread_create(sorfttimer_process);

    app_init();

    std::cout << SERVER_SORFT_VERSION << ":Started" << endl;

    while (1)
    {   
        ws_client_process();
        sleep(3);
        std::cout << SERVER_SORFT_VERSION << ":Conneting..." << endl;
    }
    
    return 0;
}